
package com.ukao.steward.pesenter.valetRunners;

import com.ukao.steward.base.BasePresenter;
import com.ukao.steward.bean.BlankTableBean;
import com.ukao.steward.bean.StringBean;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.consts.SaveParams;
import com.ukao.steward.retrofit.ApiCallback;
import com.ukao.steward.util.L;
import com.ukao.steward.util.T;
import com.ukao.steward.view.valetRunners.FillBlankView;

import java.util.HashMap;

/**
 * Created by ukaodev on 2017/6/28.
 */

public class FillBlankPesenter extends BasePresenter<FillBlankView> {


    public FillBlankPesenter(FillBlankView view) {
        attachView(view);
    }
    /**
     * 获取验证码
     */
    public void verifyBank(String strphonecode) {
       mvpView.showLoading();
        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("phone", strphonecode);
        mHashMap.put("accessToken", SaveParams.getToken());
        addSubscription(apiStores.verifyBank(Constant.createParameter(mHashMap)),
                new ApiCallback<StringBean>() {

                    @Override
                    public void onSuccess(StringBean model) {

                        if (model.getHttpCode() == 200) {
                            mvpView.verifyBankSucceed();

                        } else {
                            T.show(model.getMsg());
                        }

                    }

                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();


                    }
                });
    }


    public void addBankCard( HashMap mHashMap ) {
        mvpView.showLoading();
        L.i("mHashMap=" + mHashMap.toString());
        addSubscription(apiStores.addBankCard(Constant.createParameter(mHashMap)),
                new ApiCallback<StringBean>() {
                    @Override
                    public void onSuccess(StringBean model) {

                        if (model.getHttpCode() == 200) {
                                mvpView.addBankCardSucceed();


                        } else {
                            T.show(model.getMsg());
                        }

                    }

                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();


                    }
                });
    }

    /**
     * 银行卡列表
     */
    public void bankTabel( ) {
        mvpView.showLoading();
        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("accessToken", SaveParams.getToken());
        addSubscription(apiStores.bankTabel(Constant.createParameter(mHashMap)),
                new ApiCallback<BlankTableBean>() {

                    @Override
                    public void onSuccess(BlankTableBean model) {

                        if (model.getHttpCode() == 200) {
                           mvpView.bankTabelSucceed(model.getData());

                        } else {
                            T.show(model.getMsg());
                        }

                    }

                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();


                    }
                });
    }



}
